package dasom.basic;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class JoinMember
 */
@WebServlet("/JoinMember.do")
public class JoinMember extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
		res.setContentType("text/html; charset=UTF-8");
		PrintWriter out=res.getWriter();
		out.print("<html>");
		out.print("<head><title>JoinMember");
		out.print("</title></head>");
		out.print("<body><h1>회원가입</h1>");
		out.print("<form name='jm' method='post'");
		out.print("<div>아이디<input type='text' name='userid'</div>");
		out.print("<div>비밀번호<input type='pwd' name='pwd'</div>");
		out.print("<div>비밀번호 확인<input type='repwd' name='repwd'</div>");
		out.print("<div>이름<input type='text' name='name'</div>");
		out.print("<div>전자우편<input type='text' name='zip'</div>");
		out.print("<div><button type='submit'>입력완료</button>");
		out.print("<button type='submit'>다시입력</button></div>");
		out.print("</form>");
		out.print("</body>");
		out.print("</html>");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
		res.setContentType("text/html;charset=UTF-8");
		PrintWriter out = res.getWriter();
		
		req.setCharacterEncoding("UTF-8");
		
		String userid = req.getParameter("userid");
		String pwd = req.getParameter("pwd");
		String repwd = req.getParameter("repwd");
		String name = req.getParameter("name");
		String zip = req.getParameter("zip");
		
		out.print("<html>");
		out.print("<head><title>회원 가입 정보</title></head>");
		out.print("<body>");
		out.print("<h1>회원 가입 정보</h1>");
		out.print("<p> 아이디: "+userid+"<br>");
		out.print("<p> 비밀번호:"+pwd+"<br>");
		out.print("<p> 이름:"+name+"<br>");
		out.print("<p> 전자우편:"+zip+"<br>");
		out.print("</body>");
		out.print("</html>");
	}

}
